package com.gxa.controller;

import com.gxa.common.*;
import com.gxa.pojo.Emp;
import com.gxa.pojo.zk.KeyWord;
import com.gxa.service.EmpService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@Controller
@Api(value = "员工管理",tags = "员工管理接口API")
@RequestMapping(value = "/emp")
public class EmpController {

    @Autowired
    private EmpService empService;


    /**
     * 查询全部员工信息
     * @param p page实体
     * @return
     */
    @RequestMapping(value = "/queryAll" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "查询全部员工接口",notes = "查询员工基本信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public JsonResult queryAll(@RequestBody Page p){
        Integer page =p.getPage();
        Integer limit =p.getLimit();
        return empService.queryAll(page,limit);
    }



    /**
     * 查询在职员工信息
     * @param p page实体
     * @return
     */

    @RequestMapping(value = "/queryWorking" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "查询在职员工接口",notes = "传递在职员工基本信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public JsonResult queryWorking(@RequestBody Page p){
        Integer page =p.getPage();
        Integer limit =p.getLimit();
        return empService.queryWorking(page,limit);
    }

    /**
     *查询离职人员基本信息
     * @param p page实体
     * @return
     */
    @RequestMapping(value = "/queryDeparture" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "查询离职员工接口",notes = "传递离职员工基本信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public JsonResult queryDeparture( @RequestBody Page p){
        Integer page =p.getPage();
        Integer limit =p.getLimit();
        return empService.queryDeparture(page,limit);
    }

    /**
     *查询黑名单基本信息
     * @param p page实体
     * @return
     */
    @RequestMapping(value = "/queryBlackList" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "查询黑名单接口",notes = "传递黑名单基本信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public JsonResult queryBlackList(@RequestBody Page p){
        Integer page =p.getPage();
        Integer limit =p.getLimit();
        return empService.queryBlackList(page,limit);
    }

    /**
     * 录入员工信息
     * @param emp emp实体
     * @return
     */
    @RequestMapping(value = "/addEmp" )   //接口和前端传递数据方式
    @ApiOperation(value = "录入员工接口",notes = "录入员工基本信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiImplicitParams({
            @ApiImplicitParam(name = "emp_joinDepartureSta",value = "入离职状态",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_number",value = "员工编号",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_weight",value = "体重",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_height",value = "身高",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_address",value = "家庭住址",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_name",value = "姓名",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_sex",value = "性别",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_birthday",value = "生日",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_leaveTime",value = "离职时间",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_tel",value = "电话",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_departureTb",value = "离职表",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_currentAddress",value = "现住址",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_health",value = "健康情况",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_idCard",value = "身份证",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_joinTime",value = "入职时间",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_testPos",value = "年度考核情况",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_prize",value = "获奖经历",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_email",value = "邮箱",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_phone",value = "手机",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_useStatus",value = "使用状态",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_level",value = "员工级别",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_idCardAddress",value = "身份证附件(图片地址)",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_skills",value = "掌握技能",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_joinTb",value = "入职表",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_experience",value = "工作经历",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_pic",value = "照片",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_remark",value = "人员备注",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_politics",value = "政治面貌",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_native",value = "籍贯",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_dept",value = "所在部门",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_qq",value = "qq",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_maritalStatus",value = "婚姻状况",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_education",value = "学历",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_bloodType",value = "血型",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_nation",value = "民族",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_dept",value = "所在部门",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_job",value = "职务",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_title",value = "职称",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "emp_category",value = "人员类别",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R addEmp(@RequestBody Emp emp){
        return empService.addEmp(emp);
    }


//    /**
//     * 导入员工信息
//     * @return
//     */
//
//    @RequestMapping(value = "/importEmp" , method = RequestMethod.POST)   //接口和前端传递数据方式
//    @ApiOperation(value = "导入员工接口",notes = "导入员工信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
//
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=400,message="坏的请求，接收参数"),
//            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
//            @ApiResponse(code=500,message="格式错误"),
//            @ApiResponse(code=505,message="后台数据库错误")
//    })
//    @ResponseBody
//    public R importEmp(){
//        R r = new R();
//
//        r.setCode(200);
//        r.setMsg("导入成功");
//        return r;
//    }
//
//
//    /**
//     * 导出员工信息
//     * @return
//     */
//
//
//    @RequestMapping(value = "/exportEmp" , method = RequestMethod.POST)   //接口和前端传递数据方式
//    @ApiOperation(value = "导出员工接口",notes = "导出员工信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=400,message="坏的请求，接收参数"),
//            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
//            @ApiResponse(code=500,message="格式错误"),
//            @ApiResponse(code=505,message="后台数据库错误")
//    })
//    @ResponseBody
//    public R exportEmp(){
//        R r = new R();
//        r.setCode(200);
//        r.setMsg("导出成功");
//        return r;
//    }


    /**
     * 编辑员工信息
     * @param  emp 员工对象
     * @return
     */

    @RequestMapping(value = "/editEmp" )   //接口和前端传递数据方式
    @ApiOperation(value = "编辑员工接口",notes = "编辑员工信息",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiImplicitParam(name = "emp_number",value = "员工编号",required = true,dataType = "String",paramType = "query")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R editEmp(@RequestBody Emp emp){
        return empService.editEmp(emp);
    }


    /**
     * 更改员工状态为离职
     * @param emp emp实体
     * @return
     */

    @RequestMapping(value = "/setWorkingToDeparture" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "将在职员工改为离职接口",notes = "在职变离职",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R setWorkingToDeparture(@RequestBody Emp emp){
        Integer param1 = State.EMP_QUIT;
        String param2 = emp.getEmp_number();
        return empService.setWorkingToDeparture(param1,param2);
    }


    /**
     * 更改员工状态为拉黑
     * @param emp emp实体
     * @return
     */


    @RequestMapping(value = "/setDepartureToBlackList" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "将离职员工拉黑接口",notes = "离职变为黑名单",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R setDepartureToBlackList(@RequestBody Emp emp){
        Integer param1 = State.EMP_QUIT_BLACKLIST;
        String param2 = emp.getEmp_number();
        return empService.setDepartureToBlackList(param1,param2);
    }


    /**
     * 取消拉黑
     * @param emp emp实体
     * @return
     */


    @RequestMapping(value = "/setBlackListToDeparture" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "取消拉黑接口",notes = "黑名单人员变离职人员",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R setBlackListToDeparture(@RequestBody Emp emp){
        Integer param1 = State.EMP_QUIT;
        String param2 = emp.getEmp_number();
        return empService.setBlackListToDeparture(param1,param2);
    }

    /**
     * 查看员工详细信息
     * @param emp emp实体
     * @return
     */

    @RequestMapping(value = "/queryEmpDetails" , method = RequestMethod.POST)   //接口和前端传递数据方式
    @ApiOperation(value = "员工详情接口",notes = "查看员工详情",httpMethod = "POST", response = ResponseData.class)  //swagger对方法的详细描述
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏的请求，接收参数"),
            @ApiResponse(code=405,message="方法不允许，请求方式错误"),
            @ApiResponse(code=500,message="格式错误"),
            @ApiResponse(code=505,message="后台数据库错误")
    })
    @ResponseBody
    public R queryEmpDetails(@RequestBody Emp emp){
        String emp_number = emp.getEmp_number();
        return empService.queryEmpDetails(emp_number);
    }

    /**
     * 全部员工模糊查询
     * @param keyWord 关键字
     * @return
     */
    @RequestMapping(value = "/fuzzyQuery", method = RequestMethod.POST)
    @ApiOperation(value = "全部员工模糊查询", notes = "传递字符串", httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyWord", value = "关键词", required = true, dataType = "String", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务错误")
    })
    @ResponseBody
    public JsonResult fuzzyQuery(@RequestBody KeyWord keyWord) {
        String Word =keyWord.getKeyWord();
        Integer page =keyWord.getPage();
        Integer limit =keyWord.getLimit();
        return empService.fuzzyQuery(Word,page,limit);
    }

    /**
     * 在职员工模糊查询
     * @param keyWord 关键字
     * @return
     */
    @RequestMapping(value = "/fuzzyQueryWorking", method = RequestMethod.POST)
    @ApiOperation(value = "在职员工模糊查询", notes = "传递字符串", httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyWord", value = "关键词", required = true, dataType = "String", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务错误")
    })
    @ResponseBody
    public JsonResult fuzzyQueryWorking(@RequestBody KeyWord keyWord) {
        String Word =keyWord.getKeyWord();
        Integer page =keyWord.getPage();
        Integer limit =keyWord.getLimit();
        return empService.fuzzyQueryWorking(Word,page,limit);
    }
    /**
     * 离职员工模糊查询
     * @param keyWord 关键字
     * @return
     */
    @RequestMapping(value = "/fuzzyQueryDep", method = RequestMethod.POST)
    @ApiOperation(value = "离职员工模糊查询", notes = "传递字符串", httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyWord", value = "关键词", required = true, dataType = "String", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务错误")
    })
    @ResponseBody
    public JsonResult fuzzyQueryDep(@RequestBody KeyWord keyWord) {
        String Word =keyWord.getKeyWord();
        Integer page =keyWord.getPage();
        Integer limit =keyWord.getLimit();
        return empService.fuzzyQueryDep(Word,page,limit);
    }

    /**
     * 黑名单模糊查询
     * @param keyWord 关键字
     * @return
     */
    @RequestMapping(value = "/fuzzyQueryBlackList", method = RequestMethod.POST)
    @ApiOperation(value = "黑名单模糊查询", notes = "传递字符串", httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyWord", value = "关键词", required = true, dataType = "String", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务错误")
    })
    @ResponseBody
    public JsonResult fuzzyQueryBlackList(@RequestBody KeyWord keyWord) {
        String Word =keyWord.getKeyWord();
        Integer page =keyWord.getPage();
        Integer limit =keyWord.getLimit();
        return empService.fuzzyQueryBlackList(Word,page,limit);
    }


    @RequestMapping(value = "/queryMaritalSta", method = RequestMethod.GET)
    @ApiOperation(value = "婚姻状况下拉框查询", notes = "婚姻状况下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryMaritalSta(){
        return empService.queryMaritalSta();
    }

    @RequestMapping(value = "/queryBloodType", method = RequestMethod.GET)
    @ApiOperation(value = "血型下拉框查询", notes = "血型下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryBloodType(){
        return empService.queryBloodType();
    }

    @RequestMapping(value = "/queryNation", method = RequestMethod.GET)
    @ApiOperation(value = "民族下拉框查询", notes = "民族下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryNation(){
        return empService.queryNation();
    }

    @RequestMapping(value = "/queryCategory", method = RequestMethod.GET)
    @ApiOperation(value = "人员类别下拉框查询", notes = "人员类别下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryCategory(){
        return empService.queryCategory();
    }

    @RequestMapping(value = "/queryJob", method = RequestMethod.GET)
    @ApiOperation(value = "职务下拉框查询", notes = "职务下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryJob(){
        return empService.queryJob();
    }

    @RequestMapping(value = "/queryTitle", method = RequestMethod.GET)
    @ApiOperation(value = "职称下拉框查询", notes = "职称下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryTitle(){
        return empService.queryTitle();
    }

    @RequestMapping(value = "/queryEdu", method = RequestMethod.GET)
    @ApiOperation(value = "学历下拉框查询", notes = "学历下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryEdu(){
        return empService.queryEdu();
    }

    @RequestMapping(value = "/queryDept", method = RequestMethod.GET)
    @ApiOperation(value = "部门下拉框查询", notes = "部门下拉框查询", httpMethod = "GET", response = R.class)
    @ResponseBody
    public R queryDept(){
        return empService.queryDept();
    }

}
